package com.xzc.java8.B_Stream.h_reduce;

import java.util.Arrays;
import java.util.List;
import java.util.Optional;

public class SumTest {

    public static void main(String[] args) {
        List<Integer> list0 = Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 9);
        int out0 = list0.stream().reduce(0, (a, b) -> a + b);
        System.out.println(out0);

        int out1 = list0.stream().reduce(0, Integer::sum);
        System.out.println(out1);

        Optional<Integer> out2 = list0.stream().reduce(Integer::sum);
        out2.ifPresent(System.out::println);
    }
}
